/**
 * Created by yelan on 2018/8/19.
 */
import React, {Component} from 'react';
import PropTypes from 'prop-types';

class ContactList extends Component {
    render() {
        var filterContacts = this.props.contacts.filter((contact)=>{
            return contact.name.indexOf(this.props.filterText) != -1;
        });

        return (
            <ul>
                {
                    filterContacts.map((contact)=>{
                        <li key={contact.email}>{contact.name} - {contact.email}</li>
                    })
                }
            </ul>
        )
    }
}

ContactList.propTypes = {
    contacts: PropTypes.arrayOf(PropTypes.object),
    filterText: PropTypes.string.isRequired
};

export default ContactList;
